home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / NPP.PAK / NP.CPP < prev    next >
C/C++ Source or Header  |  1997-05-06  |  4KB  |  159 lines

  1. // np.cpp : Defines the class behaviors for the application.
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1995 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12. //
  13.  
  14. #include "stdafx.h"
  15. #include "np.h"
  16. #include "combobar.h"
  17. #include "mainfrm.h"
  18. #include "npdoc.h"
  19. #include "npview.h"
  20. #include <locale.h>
  21.  
  22. #ifdef _DEBUG
  23. #undef THIS_FILE
  24. static char BASED_CODE THIS_FILE[] = __FILE__;
  25. #endif
  26.  
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CNotepadApp
  29.  
  30. BEGIN_MESSAGE_MAP(CNotepadApp, CWinApp)
  31.     //{{AFX_MSG_MAP(CNotepadApp)
  32.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  33.     //}}AFX_MSG_MAP
  34.     // Standard file based document commands
  35.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  36.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  37.     // Standard print setup command
  38.     ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  39. END_MESSAGE_MAP()
  40.  
  41. /////////////////////////////////////////////////////////////////////////////
  42. // CNotepadApp construction
  43.  
  44. CNotepadApp::CNotepadApp()
  45. {
  46. }
  47.  
  48. /////////////////////////////////////////////////////////////////////////////
  49. // The one and only CNotepadApp object
  50.  
  51. CNotepadApp theApp;
  52.  
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CNotepadApp initialization
  55.  
  56. BOOL CNotepadApp::InitInstance()
  57. {
  58.     _tsetlocale(LC_ALL, _T(""));
  59.  
  60.     // Standard initialization
  61.  
  62.     Enable3dControls();
  63.  
  64.     LoadStdProfileSettings(8);  // Load standard INI file options (including MRU)
  65.  
  66.     // Register document templates
  67.  
  68.     CSingleDocTemplate* pDocTemplate;
  69.     pDocTemplate = new CSingleDocTemplate(
  70.         IDR_MAINFRAME,
  71.         RUNTIME_CLASS(CNotepadDoc),
  72.         RUNTIME_CLASS(CMainFrame),       // main SDI frame window
  73.         RUNTIME_CLASS(CNotepadView));
  74.     AddDocTemplate(pDocTemplate);
  75.  
  76. #ifndef _MAC
  77.     // open file specified on command line
  78.     if (m_lpCmdLine[0] == 0)
  79.         OnFileNew();
  80.     else
  81.         OpenDocumentFile(m_lpCmdLine);
  82. #endif
  83.  
  84. #ifdef _MAC
  85.     // Enable drag/drop open
  86.     m_pMainWnd->DragAcceptFiles();
  87. #endif
  88.  
  89.     return TRUE;
  90. }
  91.  
  92. /////////////////////////////////////////////////////////////////////////////
  93. // CAboutDlg dialog used for App About
  94.  
  95. class CAboutDlg : public CDialog
  96. {
  97. public:
  98.     CAboutDlg();
  99.  
  100. // Dialog Data
  101.     //{{AFX_DATA(CAboutDlg)
  102.     enum { IDD = IDD_ABOUTBOX };
  103.     //}}AFX_DATA
  104.  
  105. // Implementation
  106. protected:
  107.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  108.     //{{AFX_MSG(CAboutDlg)
  109.         // No message handlers
  110.     //}}AFX_MSG
  111.     DECLARE_MESSAGE_MAP()
  112. };
  113.  
  114. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  115. {
  116.     //{{AFX_DATA_INIT(CAboutDlg)
  117.     //}}AFX_DATA_INIT
  118. }
  119.  
  120. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  121. {
  122.     CDialog::DoDataExchange(pDX);
  123.     //{{AFX_DATA_MAP(CAboutDlg)
  124.     //}}AFX_DATA_MAP
  125. }
  126.  
  127. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  128.     //{{AFX_MSG_MAP(CAboutDlg)
  129.         // No message handlers
  130.     //}}AFX_MSG_MAP
  131. END_MESSAGE_MAP()
  132.  
  133. // App command to run the dialog
  134. void CNotepadApp::OnAppAbout()
  135. {
  136.     CAboutDlg aboutDlg;
  137.     aboutDlg.DoModal();
  138. }
  139.  
  140. /////////////////////////////////////////////////////////////////////////////
  141. // CNotepadApp commands
  142.  
  143. BOOL CNotepadApp::OnIdle(LONG lCount) 
  144. {
  145.     CMainFrame* pFrame = (CMainFrame*) AfxGetMainWnd();
  146.     CStatusBar* pStatusBar = (CStatusBar*) pFrame->GetDescendantWindow(AFX_IDW_STATUS_BAR);
  147.  
  148.     if(pStatusBar)
  149.     {
  150.         CEdit &edit = ((CEditView*)pFrame->GetActiveView())->GetEditCtrl();
  151.         CString s1;
  152.         UINT i = edit.LineFromChar();
  153.         s1.Format(_T("Ln %u"), ++i);
  154.         pStatusBar->SetPaneText(pStatusBar->CommandToIndex(ID_INDICATOR_LINE), s1);
  155.     }
  156.  
  157.     return CWinApp::OnIdle(lCount);
  158. }
  159.